define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermanage/roomonline/index',
                    add_url: 'usermanage/roomonline/add',
                    edit_url: 'usermanage/roomonline/edit',
                    del_url: 'usermanage/roomonline/del',
                    multi_url: 'usermanage/roomonline/multi',
                    table: 'v_roomonline',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'uid',
                sortName: 'uid',
				search: false, //默认主键id搜索框
                showColumns:true,//选择要显示的列
                showToggle:true,//表格的显示样式
                searchFormVisible:false,//搜索框是否在顶部默认显示
                shwoExport:true,//导出按钮
                commonSearch: false,
                columns: [
                    [
                        {field: 'uid', title: __('Uid')},
                        {field: 'nickname', title: __('Nickname')},
                        {field: 'roomId', title: __('Roomid')},
                        {field: 'kindId', title: __('Kindid')},
                        {field: 'maxRound', title: __('Maxround')},
                        {field: 'joinTime', title: __('Jointime'),formatter: Table.api.formatter.datetimes},
						{field: 'duration', title: __('Duration')},
                        {field: 'online', title: __('Online'), formatter: Table.api.formatter.status},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});